using System;
using System.Data;
using System.Collections.Generic;

namespace shfa.snomtastic.data.business
{
    public partial class ModelController
    {
		private ModelInfo ObjectFromDataRow(DataRow dr)
        {
            if (dr != null)
            {
				ModelInfo obj = new ModelInfo();
				obj.ModelId = dr.Field<Guid>("ModelId"); 
				obj.Name = (dr["Name"] != DBNull.Value) ? dr.Field<String>("Name") : string.Empty; 
				obj.ErrorMessage = (dr["ErrorMessage"] != DBNull.Value) ? dr.Field<String>("ErrorMessage") : string.Empty; 
				obj.ConfigurationId = (dr["ConfigurationId"] != DBNull.Value) ? dr.Field<Guid>("ConfigurationId") : Guid.Empty; 
				return obj;
            }
            return null;
        }

        private List<ModelInfo> ListFromDataTable(DataTable dt)
        {
            List<ModelInfo> lst = new List<ModelInfo>();

            foreach (DataRow dr in dt.Rows)
            {
                lst.Add(ObjectFromDataRow(dr));
            }

            return lst;
        }
    }
}
